package com.abaaba.project2.service.serviceImpl;

import com.abaaba.project2.bean.System;
import com.abaaba.project2.bean.bo.ConfigOrderBO;
import com.abaaba.project2.bean.vo.MallConfigOrderVO;
import com.abaaba.project2.mapper.SystemMapper;
import com.abaaba.project2.service.MallConfigOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author Hedgehog
 * @Date 2021/6/6 22:46
 * @Version 1.0
 */
@Service
public class MallCofigOrderServiceImpl implements MallConfigOrderService {

    @Autowired
    SystemMapper systemMapper;

    @Override
    public MallConfigOrderVO selectCofigOrder() {

        System systemConfirm = systemMapper.selectByPrimaryKey(35);
        System systemUnpaid = systemMapper.selectByPrimaryKey(33);
        System systemComment = systemMapper.selectByPrimaryKey(42);
        //获取值
        String confirm = systemConfirm.getKeyValue();
        String unpaid = systemUnpaid.getKeyValue();
        String comment = systemComment.getKeyValue();

        //封装
        MallConfigOrderVO mallConfigOrderVO = new MallConfigOrderVO();
        mallConfigOrderVO.setCskaoyanmall_order_comment(comment);
        mallConfigOrderVO.setCskaoyanmall_order_unconfirm(confirm);
        mallConfigOrderVO.setCskaoyanmall_order_unpaid(unpaid);
        return mallConfigOrderVO;
    }

    @Override
    public void updateCofigOrder(ConfigOrderBO configOrderBO) {
        System systemComment = new System();
        systemComment.setId(42);
        systemComment.setKeyValue(configOrderBO.getCskaoyanmall_order_comment());

        System systemUnconfirm = new System();
        systemUnconfirm.setId(35);
        systemUnconfirm.setKeyValue(configOrderBO.getCskaoyanmall_order_unconfirm());

        System systemUnpaid = new System();
        systemUnpaid.setId(44);
        systemUnpaid.setKeyValue(configOrderBO.getCskaoyanmall_order_unpaid());

        systemMapper.updateByPrimaryKeySelective(systemComment);
        systemMapper.updateByPrimaryKeySelective(systemUnconfirm);
        systemMapper.updateByPrimaryKeySelective(systemUnpaid);

    }


}
